<?php

// SfTuts/JobeetBundle/Controller/JobController.php

namespace SfTuts\JobeetBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller,
    SfTuts\JobeetBundle\Entity\Job;

class JobController extends Controller
{
    public function createAction()
    {

        $em = $this->get('doctrine.orm.entity_manager');

        $category = new Category();
        $category->setName('Programming');
        $em->persist($category);

        $job = new Job();

        $job->setCategory($category);
        $em->persist($job);

        $em->flush();

        // ...
    }

    public function editAction($id)
    {
        $em = $this->get('doctrine.orm.entity_manager');

        $job = $em->find('SfTutsJobeetBundle:Job', $id);
        $job->setPosition('Web designer');

        $em->persist($job);
        $em->flush();

        // ...
    }

    public function deleteAction($id)
    {
        $em = $this->get('doctrine.orm.entity_manager');

        $job = $em->find('SfTutsJobeetBundle:Job', $id);

        $em->remove($job);
        $em->flush();

        // ...
    }
}